/*
 * CrateVisionNode.h
 *
 *  Created on: Jan 16, 2012
 *      Author: rick
 */

#ifndef CrateVisionNode_H_
#define CrateVisionNode_H_

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <iostream>
#include <stdio.h>
#include <FiducialDetector.h>
#include <pcrctransformation/pcrctransformer.hpp>
#include <pcrctransformation/point2f.hpp>

#include <crate_vision/Initialize.h>
#include <crate_vision/Detect.h>

#include <vision/CrateEventMsg.h>
#include <crate_vision/TopViewMsg.h>

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <unicap_cv_bridge.hpp>
#include <CameraCalibration/RectifyImage.h>

using namespace cv;
using namespace unicap_cv_bridge;
using namespace std;
using namespace pcrctransformation;

class CrateVisionNode {
public:
	CrateVisionNode(int argc, char* argv[]);
	virtual ~CrateVisionNode();

	void sendBox();

	void moveCallback(const vision::CrateEventMsg::ConstPtr&);
	void data_request(const crate_vision::TopViewMsg::ConstPtr&);

	void get_xml_data(String);

private:
	unicap_cv_camera cam;
	double cam_x, cam_y; //Position of the camera in the coordination system of the delta robot. This is calculated during initialization
	double cam_height; //This is a fixed position measured by us manually: 210 mm.

	
	ros::Publisher pub;
	ros::ServiceClient viewCheck;
	
	String crate_name;

	bool initialized;

	char* xml_path;

	FiducialDetector* fidDetector;
	point2f::point2fvector rc, markers;
	Initialize* init;

	RectifyImage rectifier;
	Mat final_crate, final_frame, reference, frameRectified;
};

#endif /* CrateVisionNode_H_ */
